package test0109;

public class Test02 {
    public static void main(String[] args) {
        // (2)统计字符串中某个字符串出现的次数
        String s = "lskdabcjfsaabcdkfhwerwerabc";
        int i = m(s, "abc");
        System.out.println(i);
    }
    public static int m(String s, String sub) {
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.startsWith(sub, i)) {
                count++;
                i += sub.length() -1 ;
            }
        }
        return count;


    }
}